<template>
  <div>
    <a-card title="提现记录">
      <a-row>
        <a-col :span="12">
          <span>提现状态：</span>
          <a-select
            style="width: 30%"
            @change="handleSearch"
            :allowClear="true"
          >
            <a-select-option value="-1">
              全部
            </a-select-option>
            <a-select-option value="1">
              已提现
            </a-select-option>
            <a-select-option value="2">
              申请中
            </a-select-option>
            <a-select-option value="3">
              已驳回
            </a-select-option>
          </a-select>
        </a-col>
      </a-row>
      <a-table
        :scroll="{ x: 1500 }"
        :columns="columns"
        :data-source="tabdatas"
        :rowKey="(record) => record.id"
        :pagination="{
          total: Number(this.total),
          showSizeChanger: true,
          showQuickJumper: true,
          current: Number(this.current),
          pageSize: Number(this.pageSize),
          size: 'small',
          pageSizeOptions: ['5', '10', '25', '50'],
          onChange: handleTableChange,
          onShowSizeChange: handleTableChange,
          showTotal: (total) => `总计 ${total} 条数据`,
        }"
        :loading="loading"
      >
      </a-table>
    </a-card>
  </div>
</template>

<script>
import dayjs from "dayjs";
import { getWithdrawal, applyHistory } from "../../services/dataSource";
export default {
  name: "sss",
  components: {},
  props: {},
  filters: {
    getTime(val) {
      return dayjs(val).format("YYYY-MM-DD");
    },
    getStatus(val) {
      return (val =
        val == 0
          ? "未处理"
          : val == 1
          ? "已审核"
          : val == 2
          ? "已拒绝"
          : "已冻结");
    },
  },
  data() {
    return {
      loading: false,
      disbNo: "",
      //   分页
      current: 1,
      pageSize: 10,
      total: 0,
      //   表格数据
      columns: [
        {
          title: "序号",
          key: "index",
          width: 80,
          customRender: function(_, __, i) {
            return i + 1;
          },
        },
        {
          title: "申请人",
          dataIndex: "tDistributor",
          align: "center",
          width: 170,
          ellipsis: true,
          customRender: function(text, record) {
            return <span>{record.tDistributor.disbName}</span>;
          },
        },
        {
          title: "申请金额（元）",
          dataIndex: "nowCashOutAmt",
          align: "center",
          width: 150,
        },
        {
          title: "银行",
          dataIndex: "bank",
          align: "center",
          width: 120,
          customRender: function(text, record) {
            return <span>{record.tDistributor.bank}</span>;
          },
        },
        {
          title: "收款账号",
          dataIndex: "bankAccount",
          align: "center",
          width: 200,
          ellipsis: true,
          customRender: function(text, record) {
            return <span>{record.tDistributor.bankAccount}</span>;
          },
        },
        {
          title: "当前状态",
          dataIndex: "status",
          align: "center",
          width: 120,
          customRender: function(val, record) {
            return (val =
              val == 1 ? (
                <a-badge color="red" text="已提现" />
              ) : val == 2 ? (
                <a-badge color="green" text="申请中" />
              ) : val == 3 ? (
                <a-badge color="blue" text="已驳回" />
              ) : (
                <a-badge color="cyan" text="未知" />
              ));
          },
        },
        {
          title: "申请时间",
          dataIndex: "creationTime",
          customRender: function(val) {
            if (val !== null) {
              return dayjs(val).format("YYYY-MM-DD hh:mm:ss");
            }
          },
        },
        {
          title: "驳回原因",
          dataIndex: "reason",
        },
        {
          title: "处理时间",
          dataIndex: "handleTime",
          customRender: function(val) {
            if (val !== null) {
              return dayjs(val).format("YYYY-MM-DD hh:mm:ss");
            }
          },
        },
      ],
      tabdatas: [],
      formItemLayout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 16 },
      },
      serchStatus: -1,
    };
  },
  methods: {
    handleSearch(e) {
      this.serchStatus = parseInt(e);
      if (e == undefined) {
        this.serchStatus = -1;
      }
      this.getData();
    },
    //切换页面
    handleTableChange(pageNumber, pageSize) {
      this.current = pageNumber;
      this.pageSize = pageSize;
      this.getData();
    },
    // 获取数据
    getData() {
      const temp = {
        skipCount: (this.current - 1) * this.pageSize,
        maxResultCount: this.pageSize,
        disNo: this.disbNo,
        status: this.serchStatus,
      }; 
       applyHistory(temp).then(res=>{
         this.tabdatas = res.data.result.items
         this.total = res.data.result.totalCount
    })
    },
  },
  //声明周期 - 创建完成（可以访问当前this实例）
  created() {
    this.disbNo = window.localStorage.getItem("disbNO");
    this.getData();
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
};
</script>

<style lang="less" scoped></style>
